package com.wtc.homework;

public class Homework01 {
    public static void main(String[] args) {
        Person[] person = new Person[4];
        Person temp = null;
        person[0] = new Person("make", 15, "学生");//721
        person[1] = new Person("张三", 7, "学生");//
        person[2] = new Person("李四", 20, "学生");
        person[3] = new Person("王五", 1, "学生");
        for (int i = 0; i < person.length - 1; i++) {
            for (int j = 0; j < person.length - 1 - i; j++) {
                if (person[j].getAge() < person[j + 1].getAge()) {
                    temp = person[j];
                    person[j] = person[j + 1];
                    person[j + 1] = temp;
                }
            }
        }
        for (int i = 0; i < person.length; i++) {
            System.out.println(person[i].say());
        }
    }
}

class Person {
    private String name;
    private int age;
    private String job;

    public String say() {
        return "姓名：" + name + "，年龄：" + age + "，工作：" + job;
    }

    public Person(String name, int age, String job) {
        this.name = name;
        this.age = age;
        this.job = job;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }
}
